package interfaceLogin;

//package Interface.Customer; 

import java.awt.event.ActionEvent;
	import java.awt.event.ActionListener;

	import javax.swing.JButton;
	import javax.swing.JFrame;
	import javax.swing.JLabel;
	import javax.swing.JOptionPane;
	import javax.swing.JPasswordField;
	import javax.swing.JTextField;

	//import Entity.Customer;

public class Login extends JFrame implements ActionListener{
		private JLabel lblId;
		private JTextField txtId;
		private JLabel lblpass;
		private JPasswordField txtPass;
		private JButton btnExit;
		private JButton btnLogin;

		public Login() {
			setTitle("Customer Login");
			this.setSize(300, 184);
			this.getContentPane().setLayout(null);
			this.setDefaultCloseOperation(EXIT_ON_CLOSE);
			
			lblId = new JLabel("ID:");
			lblId.setBounds(60, 24, 20, 20);
			getContentPane().add(lblId);
			
			txtId = new JTextField();
			txtId.setBounds(124, 23, 98, 20);
			getContentPane().add(txtId);
			txtId.setText("1");

			lblpass = new JLabel("Password:");
			lblpass.setBounds(49, 51, 100, 14);
			getContentPane().add(lblpass);
			
			txtPass = new JPasswordField();
			txtPass.setBounds(124, 46, 98, 20);
			getContentPane().add(txtPass);
			txtPass.setText("1");
			
			btnExit = new JButton("Exit");
			btnExit.setBounds(22, 98, 100, 23);
			getContentPane().add(btnExit);
			btnExit.addActionListener(this);
			
			btnLogin = new JButton("Login");
			btnLogin.setBounds(163, 98, 100, 23);
			getContentPane().add(btnLogin);
			btnLogin.addActionListener(this);
			
			this.setVisible(true);
			
		}

		@Override
		public void actionPerformed(ActionEvent e) {
			
			if(e.getSource() == btnLogin) {
				if((txtId.getText().isEmpty()==false) && (txtPass.getPassword().length>0)) {
					new interfaceCustomer.CustomerFrame();
					this.setVisible(false);
				}
				else
				{
					JOptionPane.showMessageDialog(this,"Please Enter ID and Password","Error",
						    JOptionPane.ERROR_MESSAGE);
				}
			}
			if(e.getSource() == btnExit) {
				System.exit(0);
			}		
		}

		/*public void openCustomerGui(Customer customer) {
		} */

		
}  


